package com.nutrition.health.repository;

import com.nutrition.health.model.UserHealthProfile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface UserHealthProfileRepository extends JpaRepository<UserHealthProfile, Long> {

    Optional<UserHealthProfile> findByUserId(Long userId);

    @Query("SELECT p FROM UserHealthProfile p WHERE p.userId = :userId ORDER BY p.id DESC")
    List<UserHealthProfile> findAllByUserId(@Param("userId") Long userId);

    @Query("SELECT p FROM UserHealthProfile p")
    List<UserHealthProfile> findAllProfiles();
}